#include "setmqttdialog.h"
#include "ui_setmqttdialog.h"

SetMqttDialog::SetMqttDialog(SetData data,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SetMqttDialog)
{
    ui->setupUi(this);
    connect(ui->pushButton_ok,&QPushButton::clicked,this,&QDialog::accept);
    connect(ui->pushButton_cance,&QPushButton::clicked,this,&QDialog::reject);
    ui->lineEdit_ip->setText(data.mqttIp);
    ui->lineEdit_port->setText(QString::number(data.mqttPort));
    ui->lineEdit_name->setText(data.useName);
    ui->lineEdit_passwd->setText(data.usePasswd);
    ui->checkBox_autoConnect->setChecked(data.autoConnect);
    ui->checkBox_log->setChecked(data.recordLog);
    ui->checkBox_edit->setChecked(data.canEdit);
}

SetMqttDialog::~SetMqttDialog()
{
    delete ui;
}

SetData SetMqttDialog::getSetData()
{
    mData.mqttIp = ui->lineEdit_ip->text();
    mData.mqttPort = ui->lineEdit_port->text().toUInt();
    mData.useName = ui->lineEdit_name->text();
    mData.usePasswd = ui->lineEdit_passwd->text();
    mData.autoConnect = ui->checkBox_autoConnect->isChecked();
    mData.recordLog = ui->checkBox_log->isChecked();
    mData.canEdit = ui->checkBox_edit->isChecked();
    return mData;
}
